#ifndef GLOBAL_H
#define GLOBAL_H
#include <iostream>
#include <functional>
#include <QWidget>
#include <QStyle>
#include <iostream>
#include <memory>
#include <mutex>

extern std::function<void(QWidget*)> repolish;

enum ReqId
{
    ID_GET_VARIFY_CODE = 1001,//获取验证码
    ID_REG_USER = 1002,//注册用户
    ID_RESET_PASSWORD = 1003,//重置密码
    ID_LOGIN = 1004,//登录
    ID_CHAT_LOGIN = 1005,//登录聊天界面
    ID_CHAT_LOGIN_RSP = 1006,//用户登陆回包
};

enum Modules
{
    REGISTERMOD = 0,//注册模块
    RESETPASSWPRDMOD,//重置密码模块
    LOGIN,//登录
};

enum ErrorCodes {
    SUCCESS = 0,
    ERR_JSON = 1, //Json解析失败
    ERR_NETWORK = 2,
    Error_Json = 1001,  //Json解析错误
    RPCFailed = 1002,  //RPC请求错误
    VarifyExpired = 1003, //验证码过期
    VarifyCodeErr = 1004, //验证码错误
    UserExist = 1005,       //用户已经存在
    PasswdErr = 1006,    //密码错误
    EmailNotMatch = 1007,  //邮箱不匹配
    PasswdUpFailed = 1008,  //更新密码失败
    PasswdInvalid = 1009,   //密码更新失败
    TokenInvalid = 1010,   //Token失效
    UidInvalid = 1011,  //uid无效
    UserNotMatch = 1012,//用户不存在
    MysqlException = 1013,//数据库查询异常
};

enum TipErr{
    TIP_SUCCESS = 0,
    TIP_EMAIL_ERR = 1,
    TIP_PWD_ERR = 2,
    TIP_CONFIRM_ERR = 3,
    TIP_PWD_CONFIRM = 4,
    TIP_VARIFY_ERR = 5,
    TIP_USER_ERR = 6
};

struct ServerInfo
{
    int Uid;
    QString Host;
    QString Port;
    QString Token;
};

//聊天界面几种模式
enum ChatUIMode{
    SearchMode, //搜索模式
    ChatMode, //聊天模式
    ContactMode, //联系模式
};

//自定义QListWidgetItem的几种类型
enum ListItemType{
    CHAT_USER_ITEM, //聊天用户
    CONTACT_USER_ITEM, //联系人用户
    SEARCH_USER_ITEM, //搜索到的用户
    ADD_USER_TIP_ITEM, //提示添加用户
    INVALID_ITEM,  //不可点击条目
    GROUP_TIP_ITEM, //分组提示条目
    LINE_ITEM,  //分割线
    APPLY_FRIEND_ITEM, //好友申请
};


enum ClickLbState{
    Normal,
    Selected,
};
//申请好友标签输入框最低长度
const int MIN_APPLY_LABEL_ED_LEN = 40;

const QString add_prefix = "添加标签 ";

const int  tip_offset = 5;


const std::vector<QString>  strs ={"hello world !",
                             "nice to meet u",
                             "New year，new life",
                            "You have to love yourself",
                            "My love is written in the wind ever since the whole world is you"};

const std::vector<QString> heads = {
    ":/images/icon_12m6y6hb65s/icon-test1.png",
    ":/images/icon_12m6y6hb65s/icon-test2.png",
    ":/images/icon_12m6y6hb65s/icon-test3.png",
    ":/images/icon_12m6y6hb65s/icon-test4.png",
    ":/images/icon_12m6y6hb65s/icon-test5.png",
    ":/images/icon_12m6y6hb65s/icon-test6.png",
    ":/images/icon_12m6y6hb65s/icon-test7.png",
    ":/images/icon_12m6y6hb65s/icon-test8.png",
    ":/images/icon_12m6y6hb65s/icon-test9.png",
};

const std::vector<QString> names = {
    "HanMeiMei",
    "Lily",
    "Ben",
    "Androw",
    "Max",
    "Summer",
    "Candy",
    "Hunter"
};

#endif // GLOBAL_H
